
//
//  ShareCell.m
//  卡片切换
//
//  Created by 上官惠阳 on 2017/2/24.
//  Copyright © 2017年 上官惠阳. All rights reserved.
//

#import "LVShareCell.h"
#import "LVShareModel.h"
#import "UIView+Layer.h"

@interface LVShareCell ()
@property (copy,nonatomic)void (^longPressBlock)(LVShareModel *model);
@property (copy,nonatomic)void (^retryShareBlock)(LVShareModel *model,LVShareCell *cell);
- (IBAction)dealAction:(id)sender;
@end
@implementation LVShareCell
{
    LVShareModel *_shareModel;

}
- (void)awakeFromNib {
    [super awakeFromNib];

    _dealView.backgroundColor = kRGBAColor(0,0,0,0.3);
}
- (void)longPressAction:(UILongPressGestureRecognizer *)longPress
{
    if (longPress.state == UIGestureRecognizerStateBegan) {

        if (_longPressBlock) {
            _longPressBlock(_shareModel);
        }
    }
}
- (void)layoutSubviews
{
    [super layoutSubviews];

    [self makeRoundedCorners];
}
- (IBAction)dealAction:(id)sender {
    if(_retryShareBlock){
        _retryShareBlock(_shareModel,self);
    }
}
- (void)loadCellWithModel:(LVShareModel *)model
{
    _shareModel = model;

}
- (void)failWithRetryShareBlock:(void (^)(LVShareModel *model,LVShareCell *cell))retryShareBlock
{
    _dealView.hidden = NO;
    [_dealBtn setImage:[UIImage imageNamed:@"retry"] forState:UIControlStateNormal];
    _retryShareBlock = retryShareBlock;
}
- (void)addLongPressWithBlock:(void (^)(LVShareModel *model))longPreBlock
{
    if (!self.gestureRecognizers) {
        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
        _longPressBlock = longPreBlock;
        longPress.minimumPressDuration = 0.8;
        [self addGestureRecognizer:longPress];
    }
}
@end
